home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / os2 / os2cl015.zip / pmgpi.h < prev    next >
C/C++ Source or Header  |  1995-11-24  |  9KB  |  292 lines

  1. /* 
  2.  
  3.  
  4.     pmgpi.h (emx+gcc) 
  5.  
  6.     1995 Giovanni Iachello
  7.     This is freeware software. You can use or modify it as you wish,
  8.     provided that the part of code that I wrote remains freeware.
  9.     Freeware means that the source code must be available on request 
  10.     to anyone.
  11.     You must also include this notice in all files derived from this
  12.     file.
  13.  
  14.  
  15. */
  16. #ifndef _PMGPI_H_
  17. #define _PMGPI_H_
  18.  
  19. #include "pmsys.h"
  20.  
  21. class PMWin;
  22. class PMPoint;
  23. class PMRect;
  24. class PMPresSpace;
  25. class PMDevContext;
  26.  
  27. struct PMPoint : public POINTL {
  28.     PMPoint() { };
  29.     PMPoint(LONG ix,LONG iy=0) { x=ix; y=iy; }
  30.     
  31.     PMPoint& operator += (PMPoint& a) { x+=a.x; y+=a.y; return *this; }
  32.     PMPoint& operator -= (PMPoint& a) { x-=a.x; y-=a.y; return *this; }
  33.     PMPoint& operator = (POINTS a) { x=(LONG)a.x; y=(LONG)a.y; return *this; }
  34. };
  35.  
  36. inline PMPoint operator + (PMPoint& a,PMPoint& b) { 
  37.     PMPoint c; 
  38.     c.x=a.x+b.x; c.y=a.y+b.y; 
  39.     return c; 
  40. }
  41.  
  42. inline PMPoint operator - (PMPoint& a,PMPoint& b) { 
  43.     PMPoint c; 
  44.     c.x=a.x-b.x; c.y=a.y-b.y; 
  45.     return c; 
  46. }
  47.  
  48. inline PMPoint operator * (PMPoint& a,int b) { 
  49.     PMPoint c; 
  50.     c.x=a.x*b; c.y=a.y*b; 
  51.     return c; 
  52. }
  53.  
  54. inline PMPoint operator / (PMPoint& a,int b) { 
  55.     PMPoint c; 
  56.     c.x=a.x/b; c.y=a.y/b; 
  57.     return c; 
  58. }
  59.  
  60. struct PMRect : public RECTL {
  61.     PMRect(LONG x1, LONG y1, LONG x2, LONG y2) { 
  62.         xLeft=x1; yBottom=y1; xRight=x2; yTop=y2;
  63.     }
  64.     PMRect(PMPoint &p1, PMPoint &p2) { 
  65.         xLeft=p1.x; yBottom=p1.y; xRight=p2.x; yTop=p2.y;
  66.     }
  67.     PMRect(POINTL &p1, POINTL &p2) { 
  68.         xLeft=p1.x; yBottom=p1.y; xRight=p2.x; yTop=p2.y;
  69.     }
  70.     PMRect() { };
  71.     PMRect& operator = ( PMWin* );
  72.     PMRect& operator += (PMPoint& a) { 
  73.         xLeft+=a.x; xRight+=a.x;
  74.         yBottom+=a.y; yTop+=a.y;
  75.         return *this; 
  76.     }
  77.     PMRect& operator -= (PMPoint& a) { 
  78.         xLeft-=a.x; xRight-=a.x;
  79.         yBottom-=a.y; yTop-=a.y;
  80.         return *this; 
  81.     }
  82. };
  83.  
  84. /////////////////////////////////////////////////////////////////////////////
  85.  
  86. class PMPointer {
  87.     HPOINTER ptr;
  88. public:
  89.     PMPointer(ULONG idres) {
  90.         ptr=WinLoadPointer (HWND_DESKTOP,NULLHANDLE,idres);
  91.     }
  92.     ~PMPointer() {
  93.         WinDestroyPointer(ptr);
  94.     }
  95.     void set() {
  96.         WinSetPointer(HWND_DESKTOP,ptr);
  97.     }
  98.     void reset() { // rimette puntatore di sistema.
  99.         WinSetPointer(HWND_DESKTOP,
  100.             WinQuerySysPointer (HWND_DESKTOP, SPTR_ARROW, FALSE));
  101.     }
  102. };
  103.  
  104. /////////////////////////////////////////////////////////////////////////////
  105.  
  106. class PMLogFont {
  107. protected:
  108.     FATTRS fat;
  109.     LONG lLcid;
  110. public:
  111.     friend PMPresSpace;
  112.  
  113.     PMLogFont(PMPresSpace& ps,PCCH szFacename, LONG lMaxBaselineExt, LONG lAveCharWidth, USHORT usCodePage);
  114.     PMLogFont(PMPresSpace& ps,PFATTRS pfAttrs);
  115. };
  116.  
  117. /////////////////////////////////////////////////////////////////////////////
  118.  
  119. class PMMenu {
  120. protected:
  121.     HWND menu;
  122.     PMWin* win;
  123. public:
  124.     PMMenu(PMWin* iwin);  // menu' della finestra
  125.     PMMenu(HWND menu); // menu qualsiasi
  126. PMMenu(); // costruttore vuoto, per le classi derivate..
  127.     BOOL checkItem(SHORT id,SHORT fcheck) {
  128.         return WinCheckMenuItem(menu,id,fcheck);
  129.     }
  130.     BOOL enableItem(SHORT id,SHORT fEnable) {
  131.         return WinEnableMenuItem(menu,id,fEnable);
  132.     }
  133.     BOOL isItemChecked(SHORT id) {
  134.         return WinIsMenuItemChecked(menu,id);
  135.     }
  136.     BOOL isItemEnabled(SHORT id) {
  137.         return WinIsMenuItemEnabled(menu,id);
  138.     }
  139.     BOOL isItemValid(SHORT id) {
  140.         return WinIsMenuItemValid(menu,id);
  141.     }                 
  142.     BOOL setItemText(SHORT id,PSZ psz) {
  143.         return WinSetMenuItemText(menu,id,psz);
  144.     }
  145. };
  146.  
  147. class PMSystemMenu : PMMenu {
  148. public:
  149.     PMSystemMenu(PMWin* iwin);  // menu' di sistema della finestra
  150. };
  151.  
  152. class PMPopupMenu : PMMenu {
  153. public:
  154.     PMPopupMenu(PMWin* iwin,ULONG idres); // menu' popup
  155.     BOOL popup(PMPoint& pt,ULONG sel,ULONG flags=PU_POSITIONONITEM|PU_MOUSEBUTTON1|PU_MOUSEBUTTON2|PU_KEYBOARD);
  156. };
  157.  
  158. /////////////////////////////////////////////////////////////////////////////
  159.  
  160. class PMDeviceContext {
  161. protected:
  162.     HDC hdc;
  163.     HAB hab;
  164. public:
  165.     PMDeviceContext(HAB ab,HDC ihdc=NULLHANDLE); // o specifichi l'ab solo e il DC lo prendi dopo
  166.     PMDeviceContext(HAB ab,LONG lType, PCSZ pszToken="*", LONG lCount=0, PDEVOPENDATA pdopData=NULL, HDC hdcComp=NULLHANDLE); // oppure fai tutto subito.
  167.     virtual ~PMDeviceContext();
  168.     HDC open(LONG lType, PCSZ pszToken="*", LONG lCount=0, PDEVOPENDATA pdopData=NULL, HDC hdcComp=NULLHANDLE);
  169.     HMF close() { return DevCloseDC ( hdc); }
  170.     LONG escape(LONG lCode, LONG lInCount, PBYTE pbInData, PLONG plOutCount=NULL, PBYTE pbOutData=NULL) {
  171.         return DevEscape (hdc, lCode,lInCount, pbInData,plOutCount, pbOutData);
  172.     }    
  173.     BOOL queryCaps(LONG lStart, LONG lCount, PLONG alArray) {
  174.         return DevQueryCaps (hdc,lStart,lCount,alArray);
  175.     }
  176.     operator HDC () { return hdc; }
  177. };
  178.  
  179. class PMMemoryDC : public PMDeviceContext {
  180. protected:
  181. public:
  182.     PMMemoryDC(HAB ab);  // come sopra
  183.     PMMemoryDC(HAB ab,LONG lCount=0, HDC hdcComp=NULLHANDLE);
  184.     ~PMMemoryDC();
  185. };
  186.  
  187. class PMPrinterDC : public PMDeviceContext {
  188. protected:
  189.     DEVOPENSTRUC dop;
  190.     CHAR achPrnData[256],achDefPrnName[34];
  191.     DRIVDATA driv;
  192. public:
  193.     PMPrinterDC(HAB ab); // come sopra
  194.     PMPrinterDC(HAB ab,LONG lCount, PDEVOPENDATA pdopData, HDC hdcComp);
  195.     ~PMPrinterDC();
  196.     HDC open();
  197.     LONG startDoc(PSZ);
  198.     LONG endDoc(PSZ);
  199.     LONG newFrame();
  200.     LONG abortDoc();
  201.     BOOL getInformation(PSZ szDefPrnName,PSZ szPrnData,PDEVOPENSTRUC pdop);
  202. };
  203.  
  204. class PMPresSpace {
  205. protected:
  206.     HPS hps;
  207. public:
  208.     LONG lFontIdcount;
  209. public:
  210.     PMPresSpace() { lFontIdcount=1L; }
  211.     PMPresSpace(PMDeviceContext*,LONG width,LONG height,LONG flOptions,HAB ab);
  212.     virtual ~PMPresSpace();
  213.     operator HPS () { return hps; }
  214.  
  215.     BOOL setColor(LONG lColor) 
  216.         {     return GpiSetColor(hps,lColor); }
  217.     BOOL setLineType(LONG lLineType) 
  218.         {     return GpiSetLineType (hps, lLineType);    }
  219.     LONG drawText(LONG cchText, PCCH lpchText, PRECTL prcl, LONG clrFore, LONG clrBack, ULONG flCmd)
  220.         {    return WinDrawText(hps,cchText,lpchText,prcl,clrFore,clrBack,flCmd); }
  221.     BOOL fillRect(PRECTL rect, LONG lColor) 
  222.         {    return WinFillRect(hps, rect, lColor); }
  223.     LONG line(PPOINTL point) 
  224.         {    return GpiLine (hps, point); }
  225.     LONG move(PPOINTL point) 
  226.         {    return GpiMove (hps, point); }
  227.     BOOL setMix(LONG lMixMode) 
  228.         {    return GpiSetMix (hps, lMixMode); }
  229.     LONG box(LONG lControl, PPOINTL pptlPoint, LONG lHRound=0L, LONG lVRound=0L)
  230.         {     return GpiBox (hps, lControl, pptlPoint, lHRound, lVRound); }
  231.  
  232.     LONG intersectClipRectangle (__const__ RECTL *prclRectangle) 
  233.         {    return GpiIntersectClipRectangle (hps, prclRectangle); }
  234.  
  235.     HDC queryDevice() 
  236.         {     return GpiQueryDevice (hps); }
  237.     BOOL queryCharBox(PSIZEF psizfxSize) 
  238.         {     return GpiQueryCharBox (hps, psizfxSize); }
  239.     BOOL queryFontMetrics(PFONTMETRICS pfmMetrics) 
  240.         {     return GpiQueryFontMetrics (hps, sizeof(FONTMETRICS), pfmMetrics); }
  241.     BOOL queryPageViewport (PRECTL prclViewport)
  242.         {     return GpiQueryPageViewport (hps,prclViewport);    }
  243.     BOOL queryTextBox (LONG lCount1, PCH pchString, LONG lCount2, PPOINTL aptlPoints)
  244.         {     return GpiQueryTextBox (hps, lCount1, pchString, lCount2, aptlPoints); }
  245.     BOOL queryTextBox (PSZ pszString, LONG lCount2, PPOINTL aptlPoints);
  246.     LONG queryTextBoxWidth (PSZ pszString);
  247.     LONG queryTextBoxHeight (PSZ pszString);
  248.  
  249.     BOOL set(PSIZEL psizlsize,ULONG flOptions)
  250.         {    return GpiSetPS(hps,psizlsize,flOptions); }
  251.     BOOL setPageViewport (__const__ RECTL *prclViewport)
  252.         {    return GpiSetPageViewport (hps, prclViewport); }
  253.  
  254.     BOOL setCharSet(LONG llcid) 
  255.         {    return GpiSetCharSet (hps, llcid); }
  256.     BOOL setCharAngle (__const__ GRADIENTL *pgradlAngle)
  257.         {     return GpiSetCharAngle (hps,pgradlAngle); }
  258.     BOOL setCharBox (__const__ SIZEF *psizfxBox) 
  259.         {    return GpiSetCharBox (hps,psizfxBox); }
  260.     BOOL setCharBreakExtra (FIXED BreakExtra)
  261.         {    return GpiSetCharBreakExtra (hps,BreakExtra); }
  262.     BOOL setCharDirection (LONG lDirection)
  263.         {    return GpiSetCharDirection (hps, lDirection); }
  264.     BOOL setCharExtra (FIXED Extra)
  265.         {    return GpiSetCharExtra (hps, Extra); }
  266.     BOOL setCharMode (LONG lMode) 
  267.         {    return GpiSetCharMode (hps, lMode); }
  268.     BOOL setCharSet(PMLogFont& lf) 
  269.         {    return GpiSetCharSet (hps, lf.lLcid); }
  270.     LONG charString (LONG lCount, PCCH pchString)
  271.         {    return GpiCharString (hps, lCount, pchString); }
  272.     LONG charStringAt (__const__ POINTL *pptlPoint, LONG lCount, PCCH pchString)
  273.         {    return GpiCharStringAt (hps, pptlPoint, lCount, pchString); }
  274.     LONG createLogFont (__const__ STR8 *pName, LONG lLcid, __const__ FATTRS *pfatAttrs)
  275.         {    return GpiCreateLogFont (hps, pName, lLcid, pfatAttrs); }
  276. };
  277.  
  278. class PMWindowPresSpace : public PMPresSpace {
  279. public:
  280.     PMWindowPresSpace(PMWin*);
  281.     ~PMWindowPresSpace();
  282. };
  283.  
  284. class PMMicroCachedPresSpace : public PMPresSpace {
  285. public:
  286.     PMMicroCachedPresSpace(PMWin*);
  287.     ~PMMicroCachedPresSpace();
  288. };
  289.  
  290. #endif
  291.  
  292.